




public class Main {

    public static void main(String[] args) {
        int i,j,t,d;
Liczba liczba;
for (i=0;i<=args.length-2;i=i+2)
{
            try
            {
                d=Integer.parseInt(args[i+1]);
                if (d<2||d>16)
{
System.out.println("Zla podstawa "+args[i]+"["+args[i+1]+"]");
continue;
}
                try
                {
                    t=Integer.parseInt(args[i]);
                    if (t<0)
                    {
System.out.println("Dane ujemne "+args[i]+"["+args[i+1]+"]");
continue;
                    }
                    try
                    {
if (d==10)
liczba=new Liczba(t);
else
liczba=new Liczba(args[i],d);
                    }
                    catch (LiczbaException w)
                    {
System.out.println(w.getMessage()+" "+args[i]+"["+args[i+1]+"]");
continue;
                    }
                    //for (j=2;j<=16;j++)
//System.out.println("Zapis w systemie "+j+" liczby "+args[i]+"["+args[i+1]+"]"+" wynosi: "+liczba.zapis(j));
                }
                catch (NumberFormatException ex)
                {
                    try
                    {
                    liczba=new Liczba(args[i],d);
                    }
                    catch (LiczbaException w)
                    {
System.out.println(w.getMessage()+" "+args[i]+"["+args[i+1]+"]");
continue;
                    } 
                }
                
            for (j=2;j<=16;j++)
                System.out.println("Zapis w systemie "+j+" liczby "+args[i]+"["+args[i+1]+"]"+" wynosi: "+liczba.zapis(j));
            }
            catch (NumberFormatException ex)
            {
                System.out.println("Zla podstawa "+args[i]+"["+args[i+1]+"]2");
continue;
            }
}
    }
}